package com.dime.basic.api.factory;

import com.dime.basic.api.RemoteHealthadviceService;
import com.dime.basic.api.domain.DimeBasehealthadvice;
import com.dime.basic.api.model.healthDto;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteHealthadviceFallbackFactory implements FallbackFactory<RemoteHealthadviceService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteHealthadviceFallbackFactory.class);

    @Override
    public RemoteHealthadviceService create(Throwable cause) {
        log.error("蝶美细项服务调用失败:{}", cause.getMessage());

        return new RemoteHealthadviceService() {

            @Override
            public R<List<DimeBasehealthadvice>> getHealthadviceList(DimeBasehealthadvice dimeBasehealthadvice,String source) {
                return R.fail("查询健康建议信息:" + cause.getMessage());
            }

            @Override
            public R<List<DimeBasehealthadvice>> getHealthadviceBygroupIdsList(String[] groupids,String source) {
                return R.fail("查询健康建议信息:" + cause.getMessage());
            }

            @Override
            public R<List<healthDto>> gethealthDtoList(String[] groupids, String source) {
                return R.fail("查询健康建议信息:" + cause.getMessage());
            }
        };
    }
}